package mymaggi.serienjunkiesmonitor;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

import org.apache.log4j.Logger;

public class GetHtml {

	private static Logger logger = Logger.getRootLogger();
	private static String getUrl;

	public GetHtml(String url) {
		getUrl = url;
	}

	public String getHtml() {
		logger.debug("Quelltext wird eingelesen.");
		String url = getUrl;
		StringBuilder sb = new StringBuilder();
		try {
			Scanner scanner = new Scanner(new URL(url).openStream());
			while (scanner.hasNextLine()) {
				sb.append(scanner.nextLine() + "\n");
			}
			scanner.close();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		logger.debug("Quelltext wurde eingelesen.");
		return sb.toString();
	} // fetchPage

}
